package hotel;

import java.util.ArrayList;

public class Database implements DatabaseInterface{
	ArrayList<User> users;
	ArrayList<Hotel> hotels;
	ArrayList<Owner> owners;
	
	public Database()
	{
		users = new ArrayList<User>();
		hotels = new ArrayList<Hotel>();
		owners = new ArrayList<Owner>();
	}
	
	@Override
	public ArrayList<User> getUserList() {
		return users;
	}

	@Override
	public ArrayList<Hotel> getHotelList() 
	{
		return hotels;
	}
	
	public ArrayList<Owner> getOwnerList() 
	{
		return owners;
	}
	public boolean addHotel(Hotel h){
		for(int i = 0; i < hotels.size(); i++ )
			if(hotels.get(i).getName().equals(h.getName()))
				return false;
		hotels.add(h);
		return true;
	}
	public boolean addUser(User u)
	{
		for(int i = 0; i < users.size(); i++ )
			if(users.get(i).getName().equals(u.getName()))
				return false;
		users.add(u);
		return true;
	}
	
	public boolean addOwner(Owner o)
	{
		for(int i = 0; i < owners.size(); i++ )
			if(owners.get(i).getName().equals(o.getName()))
				return false;
		owners.add(o);
		return true;
	}
	
	public void removeHotel(Hotel h){
		for(int i = 0;i<hotels.size(); i++){
			if(hotels.get(i).getName().equals(h.getName())){
				hotels.remove(h);
			}
		}
	}
}
